SELECT T.* FROM C1_SITE T WHERE (NOW() BETWEEN IFNULL(T.BEGIN_DATE, NOW()) AND IFNULL(T.END_DATE, NOW())) AND EXISTS
(SELECT 1 FROM C1_site_Url e WHERE e.code = :siteUrlCode and (NOW() BETWEEN IFNULL(e.begin_date, NOW()) AND IFNULL(e.end_date, NOW())) AND e.site_id = t.id
)